package com.wbao.dianniu.update;

import java.util.LinkedList;

import com.wbao.dianniu.data.WorkExperienceData;

public class WorkListChangeManager {

	private static LinkedList<WorkChangedListener> mListener;
	public static WorkListChangeManager instance;

	public static WorkListChangeManager getInstance() {
		if (null == instance) {
			mListener = new LinkedList<WorkChangedListener>();
			instance = new WorkListChangeManager();
		}
		return instance;
	}

	private WorkListChangeManager() {
	}

	public interface WorkChangedListener {
		public void workAddChanged(WorkExperienceData data);

		public void workRemoveChanged(int position);
		
		public void workModifyChanged(int id, WorkExperienceData data);
	}

	public void addWorkChangeListener(WorkChangedListener listener) {
		mListener.add(listener);
	}

	public void removeWorkChangeListener(WorkChangedListener listener) {
		mListener.remove(listener);
	}

	public void notifyAdd(WorkExperienceData data) {
		for (int i = 0; i < mListener.size(); i++) {
			mListener.get(i).workAddChanged(data);
		}
	}

	public void notifyRemove(int position) {
		for (int i = 0; i < mListener.size(); i++) {
			mListener.get(i).workRemoveChanged(position);
		}
	}
	public void notifyModify(int position, WorkExperienceData data) {
		for (int i = 0; i < mListener.size(); i++) {
			mListener.get(i).workModifyChanged(position, data);
		}
	}
}
